\(\int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx\) [1]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 32, antiderivative size = 91 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-a (A-i B) x+\frac {a (i A+B) \log (\cos (c+d x))}{d}+\frac {a (A-i B) \tan (c+d x)}{d}+\frac {a (i A+B) \tan ^2(c+d x)}{2 d}+\frac {i a B \tan ^3(c+d x)}{3 d} \]

[Out]

-a*(A-I*B)*x+a*(I*A+B)*ln(cos(d*x+c))/d+a*(A-I*B)*tan(d*x+c)/d+1/2*a*(I*A+B)*tan(d*x+c)^2/d+1/3*I*a*B*tan(d*x+
c)^3/d

Rubi [A] (verified)

Time = 0.13 (sec) , antiderivative size = 91, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.125, Rules used = {3673, 3609, 3606, 3556} \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {a (B+i A) \tan ^2(c+d x)}{2 d}+\frac {a (A-i B) \tan (c+d x)}{d}+\frac {a (B+i A) \log (\cos (c+d x))}{d}-a x (A-i B)+\frac {i a B \tan ^3(c+d x)}{3 d} \]

[In]

Int[Tan[c + d*x]^2*(a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

-(a*(A - I*B)*x) + (a*(I*A + B)*Log[Cos[c + d*x]])/d + (a*(A - I*B)*Tan[c + d*x])/d + (a*(I*A + B)*Tan[c + d*x
]^2)/(2*d) + ((I/3)*a*B*Tan[c + d*x]^3)/d

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3609

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*
((a + b*Tan[e + f*x])^m/(f*m)), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3673

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(
e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[B*d*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e
 + f*x])^m*Simp[A*c - B*d + (B*c + A*d)*Tan[e + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, m}, x] && NeQ[b
*c - a*d, 0] &&  !LeQ[m, -1]

Rubi steps \begin{align*} \text {integral}& = \frac {i a B \tan ^3(c+d x)}{3 d}+\int \tan ^2(c+d x) (a (A-i B)+a (i A+B) \tan (c+d x)) \, dx \\ & = \frac {a (i A+B) \tan ^2(c+d x)}{2 d}+\frac {i a B \tan ^3(c+d x)}{3 d}+\int \tan (c+d x) (-a (i A+B)+a (A-i B) \tan (c+d x)) \, dx \\ & = -a (A-i B) x+\frac {a (A-i B) \tan (c+d x)}{d}+\frac {a (i A+B) \tan ^2(c+d x)}{2 d}+\frac {i a B \tan ^3(c+d x)}{3 d}-(a (i A+B)) \int \tan (c+d x) \, dx \\ & = -a (A-i B) x+\frac {a (i A+B) \log (\cos (c+d x))}{d}+\frac {a (A-i B) \tan (c+d x)}{d}+\frac {a (i A+B) \tan ^2(c+d x)}{2 d}+\frac {i a B \tan ^3(c+d x)}{3 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.07 (sec) , antiderivative size = 86, normalized size of antiderivative = 0.95 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {a \left (-6 (A-i B) \arctan (\tan (c+d x))+6 (i A+B) \log (\cos (c+d x))+6 (A-i B) \tan (c+d x)+3 (i A+B) \tan ^2(c+d x)+2 i B \tan ^3(c+d x)\right )}{6 d} \]

[In]

Integrate[Tan[c + d*x]^2*(a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

(a*(-6*(A - I*B)*ArcTan[Tan[c + d*x]] + 6*(I*A + B)*Log[Cos[c + d*x]] + 6*(A - I*B)*Tan[c + d*x] + 3*(I*A + B)
*Tan[c + d*x]^2 + (2*I)*B*Tan[c + d*x]^3))/(6*d)

Maple [A] (verified)

Time = 0.20 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.04

method result size
parts \(\frac {\left (i a A +B a \right ) \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}+\frac {a A \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {i a B \left (\frac {\left (\tan ^{3}\left (d x +c \right )\right )}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(95\)
norman \(\left (i a B -a A \right ) x +\frac {\left (-i a B +a A \right ) \tan \left (d x +c \right )}{d}+\frac {\left (i a A +B a \right ) \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {i a B \left (\tan ^{3}\left (d x +c \right )\right )}{3 d}-\frac {\left (i a A +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(96\)
derivativedivides \(\frac {a \left (\frac {i B \left (\tan ^{3}\left (d x +c \right )\right )}{3}+\frac {i A \left (\tan ^{2}\left (d x +c \right )\right )}{2}-i B \tan \left (d x +c \right )+\frac {B \left (\tan ^{2}\left (d x +c \right )\right )}{2}+A \tan \left (d x +c \right )+\frac {\left (-i A -B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (i B -A \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(97\)
default \(\frac {a \left (\frac {i B \left (\tan ^{3}\left (d x +c \right )\right )}{3}+\frac {i A \left (\tan ^{2}\left (d x +c \right )\right )}{2}-i B \tan \left (d x +c \right )+\frac {B \left (\tan ^{2}\left (d x +c \right )\right )}{2}+A \tan \left (d x +c \right )+\frac {\left (-i A -B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (i B -A \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(97\)
parallelrisch \(-\frac {-2 i a B \left (\tan ^{3}\left (d x +c \right )\right )-3 i A \left (\tan ^{2}\left (d x +c \right )\right ) a -6 i B x a d +3 i A \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a +6 A x a d +6 i B \tan \left (d x +c \right ) a -3 B \left (\tan ^{2}\left (d x +c \right )\right ) a -6 A \tan \left (d x +c \right ) a +3 B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a}{6 d}\) \(110\)
risch \(-\frac {2 i a B c}{d}+\frac {2 a A c}{d}+\frac {2 a \left (6 i A \,{\mathrm e}^{4 i \left (d x +c \right )}+9 B \,{\mathrm e}^{4 i \left (d x +c \right )}+9 i A \,{\mathrm e}^{2 i \left (d x +c \right )}+9 B \,{\mathrm e}^{2 i \left (d x +c \right )}+3 i A +4 B \right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}+\frac {a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}+\frac {i a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A}{d}\) \(134\)

[In]

int(tan(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

(I*a*A+B*a)/d*(1/2*tan(d*x+c)^2-1/2*ln(1+tan(d*x+c)^2))+a*A/d*(tan(d*x+c)-arctan(tan(d*x+c)))+I*a*B/d*(1/3*tan
(d*x+c)^3-tan(d*x+c)+arctan(tan(d*x+c)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 170 vs. \(2 (77) = 154\).

Time = 0.25 (sec) , antiderivative size = 170, normalized size of antiderivative = 1.87 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {6 \, {\left (-2 i \, A - 3 \, B\right )} a e^{\left (4 i \, d x + 4 i \, c\right )} + 18 \, {\left (-i \, A - B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} + 2 \, {\left (-3 i \, A - 4 \, B\right )} a + 3 \, {\left ({\left (-i \, A - B\right )} a e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, {\left (-i \, A - B\right )} a e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, {\left (-i \, A - B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (-i \, A - B\right )} a\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )}{3 \, {\left (d e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate(tan(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-1/3*(6*(-2*I*A - 3*B)*a*e^(4*I*d*x + 4*I*c) + 18*(-I*A - B)*a*e^(2*I*d*x + 2*I*c) + 2*(-3*I*A - 4*B)*a + 3*((
-I*A - B)*a*e^(6*I*d*x + 6*I*c) + 3*(-I*A - B)*a*e^(4*I*d*x + 4*I*c) + 3*(-I*A - B)*a*e^(2*I*d*x + 2*I*c) + (-
I*A - B)*a)*log(e^(2*I*d*x + 2*I*c) + 1))/(d*e^(6*I*d*x + 6*I*c) + 3*d*e^(4*I*d*x + 4*I*c) + 3*d*e^(2*I*d*x +
2*I*c) + d)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 167 vs. \(2 (75) = 150\).

Time = 0.35 (sec) , antiderivative size = 167, normalized size of antiderivative = 1.84 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {i a \left (A - i B\right ) \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{d} + \frac {6 i A a + 8 B a + \left (18 i A a e^{2 i c} + 18 B a e^{2 i c}\right ) e^{2 i d x} + \left (12 i A a e^{4 i c} + 18 B a e^{4 i c}\right ) e^{4 i d x}}{3 d e^{6 i c} e^{6 i d x} + 9 d e^{4 i c} e^{4 i d x} + 9 d e^{2 i c} e^{2 i d x} + 3 d} \]

[In]

integrate(tan(d*x+c)**2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x)

[Out]

I*a*(A - I*B)*log(exp(2*I*d*x) + exp(-2*I*c))/d + (6*I*A*a + 8*B*a + (18*I*A*a*exp(2*I*c) + 18*B*a*exp(2*I*c))
*exp(2*I*d*x) + (12*I*A*a*exp(4*I*c) + 18*B*a*exp(4*I*c))*exp(4*I*d*x))/(3*d*exp(6*I*c)*exp(6*I*d*x) + 9*d*exp
(4*I*c)*exp(4*I*d*x) + 9*d*exp(2*I*c)*exp(2*I*d*x) + 3*d)

Maxima [A] (verification not implemented)

none

Time = 0.39 (sec) , antiderivative size = 82, normalized size of antiderivative = 0.90 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {-2 i \, B a \tan \left (d x + c\right )^{3} + 3 \, {\left (-i \, A - B\right )} a \tan \left (d x + c\right )^{2} + 6 \, {\left (d x + c\right )} {\left (A - i \, B\right )} a + 3 \, {\left (i \, A + B\right )} a \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 6 \, {\left (A - i \, B\right )} a \tan \left (d x + c\right )}{6 \, d} \]

[In]

integrate(tan(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/6*(-2*I*B*a*tan(d*x + c)^3 + 3*(-I*A - B)*a*tan(d*x + c)^2 + 6*(d*x + c)*(A - I*B)*a + 3*(I*A + B)*a*log(ta
n(d*x + c)^2 + 1) - 6*(A - I*B)*a*tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 284 vs. \(2 (77) = 154\).

Time = 0.48 (sec) , antiderivative size = 284, normalized size of antiderivative = 3.12 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {3 i \, A a e^{\left (6 i \, d x + 6 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 3 \, B a e^{\left (6 i \, d x + 6 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 i \, A a e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 \, B a e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 i \, A a e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 \, B a e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 12 i \, A a e^{\left (4 i \, d x + 4 i \, c\right )} + 18 \, B a e^{\left (4 i \, d x + 4 i \, c\right )} + 18 i \, A a e^{\left (2 i \, d x + 2 i \, c\right )} + 18 \, B a e^{\left (2 i \, d x + 2 i \, c\right )} + 3 i \, A a \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 3 \, B a \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 6 i \, A a + 8 \, B a}{3 \, {\left (d e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate(tan(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/3*(3*I*A*a*e^(6*I*d*x + 6*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + 3*B*a*e^(6*I*d*x + 6*I*c)*log(e^(2*I*d*x + 2*I
*c) + 1) + 9*I*A*a*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + 9*B*a*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x
 + 2*I*c) + 1) + 9*I*A*a*e^(2*I*d*x + 2*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + 9*B*a*e^(2*I*d*x + 2*I*c)*log(e^(2
*I*d*x + 2*I*c) + 1) + 12*I*A*a*e^(4*I*d*x + 4*I*c) + 18*B*a*e^(4*I*d*x + 4*I*c) + 18*I*A*a*e^(2*I*d*x + 2*I*c
) + 18*B*a*e^(2*I*d*x + 2*I*c) + 3*I*A*a*log(e^(2*I*d*x + 2*I*c) + 1) + 3*B*a*log(e^(2*I*d*x + 2*I*c) + 1) + 6
*I*A*a + 8*B*a)/(d*e^(6*I*d*x + 6*I*c) + 3*d*e^(4*I*d*x + 4*I*c) + 3*d*e^(2*I*d*x + 2*I*c) + d)

Mupad [B] (verification not implemented)

Time = 7.34 (sec) , antiderivative size = 82, normalized size of antiderivative = 0.90 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (\frac {B\,a}{2}+\frac {A\,a\,1{}\mathrm {i}}{2}\right )}{d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B\,a+A\,a\,1{}\mathrm {i}\right )}{d}+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (A\,a-B\,a\,1{}\mathrm {i}\right )}{d}+\frac {B\,a\,{\mathrm {tan}\left (c+d\,x\right )}^3\,1{}\mathrm {i}}{3\,d} \]

[In]

int(tan(c + d*x)^2*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i),x)

[Out]

(tan(c + d*x)^2*((A*a*1i)/2 + (B*a)/2))/d - (log(tan(c + d*x) + 1i)*(A*a*1i + B*a))/d + (tan(c + d*x)*(A*a - B
*a*1i))/d + (B*a*tan(c + d*x)^3*1i)/(3*d)